package com.mstore.service;

import java.util.ArrayList;
import java.util.List;

import com.mstore.dao.ExamineSettingDao;
import com.mstore.pojo.Consume;
import com.mstore.pojo.ExamineSetting;

public class ExamineSettingService {

	private ExamineSettingDao examineSettingDao;
	
	/**
	 * * 通过企业id查询自动审核规则信息
	 * * @param eaId
	 * * @return
	 */
	public ExamineSetting getExamineSettingByCondition(ExamineSetting setting) {
		Object object = examineSettingDao.getExamineSettingByCondition(setting);
		return object == null ? null : (ExamineSetting) object;
	}
	
	/**
	 * * 保存新自动审核规则
	 * * @param setting
	 */
	public void addExamineSetting(ExamineSetting setting) {
		examineSettingDao.addExamineSetting(setting);
	}
	
	/**
	 * * 更新自动审核规则
	 * * @param setting
	 */
	public void updateExamineSetting(ExamineSetting setting) {
		examineSettingDao.updateExamineSetting(setting);
	}
	
	/**
	 * * 检查是否已设置过消费审核规则
	 * * @param eaId
	 * * @return
	 */
	public boolean isSetting(Long eaId) {
		return examineSettingDao.isSetting(eaId);
	}
	
	/**
	 * * 删除消费审核规则 
	 * * @param setting
	 */
	public void delExamineSetting(ExamineSetting setting) {
		examineSettingDao.delExamineSetting(setting);
	}
	
	/**
	 * * 根据条件查询消费记录
	 * * @return
	 */
	public List<Consume> getConsumesByCondition(Consume consume) {
		List<Consume> consumes = new ArrayList<Consume>();
		List<Object> list = examineSettingDao.getConsumesByCondition(consume);
		for (Object object : list) {
			consumes.add((Consume) object);
		}
		return consumes;
	}
	
	/**
	 * * 根据条件查询消费记录
	 * * 分页
	 * * @return
	 */
	public List<Consume> getPageConsumesByCondition(int index, Consume consume) {
		List<Consume> consumes = new ArrayList<Consume>();
		List<Object> list = examineSettingDao.getPageConsumesByCondition(index, consume);
		for (Object object : list) {
			consumes.add((Consume) object);
		}
		return consumes;
	}
	
	/**
	 * * 根据条件查询消费记录总数量
	 * * @return
	 */
	public int getCountConsumesByCondition(Consume consume) {
		return examineSettingDao.getCountConsumesByCondition(consume);
	}
	
	/**
	 * * 根据条件查询消费记录的总金额
	 * * @return
	 */
	public double getSumConsumesByCondition(Consume consume) {
		return examineSettingDao.getSumConsumesByCondition(consume);
	}
	
	/**
	 * * 修改消费记录审核标示
	 * * @param consume
	 */
	public void modifyConsumeExamineFlag(Consume consume) {
		examineSettingDao.modifyConsumeExamineFlag(consume);
	}

	public ExamineSettingDao getExamineSettingDao() {
		return examineSettingDao;
	}

	public void setExamineSettingDao(ExamineSettingDao examineSettingDao) {
		this.examineSettingDao = examineSettingDao;
	}

}
